Skip to content

Conversation

ndgrigorian
Copy link
Collaborator

This PR proposes copying over (with some modification) the numpy.fft helper functions fftshift, ifftshift, fftfreq, and rfftfreq.

These functions are problematic in creating circular dependencies when Intel's patched NumPy is used with SciPy. Furthermore, lazy importing creates a situation where scipy.fft = mkl_fft.interfaces.scipy_fft will reimport scipy.fft and remove the module override.

Copy link
Collaborator

@antonwolfy antonwolfy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@ndgrigorian ndgrigorian force-pushed the further-work-to-prevent-circular-dependencies branch from 28ab191 to aab894a Compare September 30, 2025 17:59
to avoid circular dependencies, also vendor (i)fftshift and (r)fftfreq from scipy
numpy constructor argument signatures were updated with a device keyword in numpy 2 and pylint fails as a result
@ndgrigorian ndgrigorian force-pushed the further-work-to-prevent-circular-dependencies branch from 227a1b8 to 0802c25 Compare September 30, 2025 19:19
@ndgrigorian
Copy link
Collaborator Author

@antonwolfy @ekomarova

with these changes, all of the following now work with mkl_fft and Intel NumPy:

import mkl_fft
import numpy.fft as fft
import scipy
scipy.fft = mkl_fft.interfaces.scipy_fft

followed by calling the respective namespaces for fftshift

@ndgrigorian ndgrigorian merged commit 6968167 into master Oct 6, 2025
85 checks passed
@ndgrigorian ndgrigorian deleted the further-work-to-prevent-circular-dependencies branch October 6, 2025 17:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants